home *** CD-ROM | disk | FTP | other *** search
- <!--- This example shows the use of CFHTTP to pull information
- dynamically from the snippets directory --->
- <HTML>
- <HEAD>
- <TITLE>
- CFHTTP Example
- </TITLE>
- </HEAD>
-
- <BASEFONT FACE="Arial, Helvetica" SIZE=2>
- <BODY bgcolor="#FFFFD5">
-
- <H3>CFHTTP Example</H3>
- <P>This example shows the ability of CFHTTP to pull
- the contents of a web resource from the Internet
- or from a local directory.
-
- <P>This example has been disabled for online viewing. Please use your copy of ColdFusion to view this example.
- <!---
- <FORM ACTION="cfhttp.cfm" METHOD="POST">
- Try entering a URL for the tag to return:
- <INPUT TYPE="Text" size=25 NAME="urladdress" VALUE="http://www.allaire.com">
- <INPUT TYPE="Submit" NAME="" VALUE="get page">
- </FORM>
-
- <!--- sets a default value for a URL to retrieve --->
- <!--- If this example fails to run correctly, you may need to
- change localhost to the name
- of the CF Server that contains CFDOCS --->
- <CFPARAM name="urladdress" default="http://localhost/cfdocs/index.htm">
-
- <!--- if we have passed a url address in the form, we
- want to display the passed address --->
- <CFIF IsDefined("form.urladdress") is True>
- <!--- do simple error check to avoid crashing the
- tag --->
- <CFIF Trim(Form.urladdress) is "" or Trim(Form.urladdress) is "http://">
- <!--- if error condition tripped, set alternative --->
- <CFSET urlAddress ="http://localhost/cfdocs/index.htm">
- <H4>because you entered no url or an empty string, the tag
- will return the following address: http://localhost/cfdocs/index.htm</H4>
-
- <CFELSE>
- <!--- otherwise use address passed from form --->
- <CFSET urlAddress = form.urladdress>
- </CFIF>
- <!--- now use the CFHTTP tag to get the file content
- represented by urladdress --->
- <CFHTTP URL="#urladdress#"
- METHOD="GET"
- RESOLVEURL=YES>
- </CFHTTP>
- <CFELSE>
- <!--- the first time through, retrieve a URL that we know
- exists --->
- <CFHTTP URL="http://localhost/cfdocs/index.htm"
- METHOD="GET"
- RESOLVEURL=YES>
- </CFHTTP>
- </CFIF>
-
- <!--- Now, output the file, including the mimetype and content --->
- <H3>Show the file</H3>
-
- <CFOUTPUT>
- <P>Your file was of type: #CFHTTP.MimeType#
- <P>#HTMLCodeFormat(CFHTTP.FileContent)#
- </CFOUTPUT>
- --->
- </BODY>
- </HTML>
-